home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / strict.z / strict
Encoding:
Text File  |  1998-10-30  |  3.0 KB  |  133 lines

  1.  
  2.  
  3.  
  4. ssssttttrrrriiiicccctttt((((3333))))                                                            ssssttttrrrriiiicccctttt((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      strict - Perl pragma to restrict unsafe constructs
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use strict;
  13.  
  14.          use strict "vars";
  15.          use strict "refs";
  16.          use strict "subs";
  17.  
  18.          use strict;
  19.          no strict "vars";
  20.  
  21.  
  22. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  23.      If no import list is supplied, all possible restrictions are assumed.
  24.      (This is the safest mode to operate in, but is sometimes too strict for
  25.      casual programming.)  Currently, there are three possible things to be
  26.      strict about:  "subs", "vars", and "refs".
  27.  
  28.      strict refs
  29.            This generates a runtime error if you use symbolic references (see
  30.            the _p_e_r_l_r_e_f manpage).
  31.  
  32.                use strict 'refs';
  33.                $ref = \$foo;
  34.                print $$ref;        # ok
  35.                $ref = "foo";
  36.                print $$ref;        # runtime error; normally ok
  37.  
  38.  
  39.      strict vars
  40.            This generates a compile-time error if you access a variable that
  41.            wasn't localized via my() or wasn't fully qualified.  Because this
  42.            is to avoid variable suicide problems and subtle dynamic scoping
  43.            issues, a merely _l_o_c_a_l() variable isn't good enough.  See the my
  44.            entry in the _p_e_r_l_f_u_n_c manpage and the local entry in the _p_e_r_l_f_u_n_c
  45.            manpage.
  46.  
  47.                use strict 'vars';
  48.                $X::foo = 1;         # ok, fully qualified
  49.                my $foo = 10;        # ok, my() var
  50.                local $foo = 9;      # blows up
  51.  
  52.            The _l_o_c_a_l() generated a compile-time error because you just touched
  53.            a global name without fully qualifying it.
  54.  
  55.      strict subs
  56.            This disables the poetry optimization, generating a compile-time
  57.            error if you try to use a bareword identifier that's not a
  58.            subroutine, unless it appears in curly braces or on the left hand
  59.            side of the "=>" symbol.
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ssssttttrrrriiiicccctttt((((3333))))                                                            ssssttttrrrriiiicccctttt((((3333))))
  71.  
  72.  
  73.  
  74.                use strict 'subs';
  75.                $SIG{PIPE} = Plumber;       # blows up
  76.                $SIG{PIPE} = "Plumber";     # just fine: bareword in curlies always ok
  77.                $SIG{PIPE} = \&Plumber;     # preferred form
  78.  
  79.  
  80.      See the section on _P_r_a_g_m_a_t_i_c _M_o_d_u_l_e_s in the _p_e_r_l_m_o_d manpage.
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.